﻿$(document).ready(function () {
    page.init();
});

var page = {
    url: "/handler/user.ashx?action=",

    init: function () {
        $("#btnReset").click(page.reset);
    },

    reset: function () {
        var oldpassword = $("#oldpassword").val();
        var newpassword = $("#newpassword").val();
        var checkpassword = $("#checkpassword").val();

        if (oldpassword == "") {
            alert("请输入原始密码");
            $("#oldpassword").focus();
            return;
        }

        if (newpassword == "") {
            alert("请输入新密码");
            $("#newpassword").focus();
            return;
        }

        if (checkpassword == "") {
            alert("请输入确认密码");
            $("#resetpassword").focus();
            return;
        }

        if (newpassword != checkpassword) {
            alert("两次密码输入不一致");
            return;
        }

        $.post(page.url + "reset", { oldPassword: oldpassword, newPassword: newpassword }, function (data) {
            if (data.error) {
                alert(data.error);
                return false;
            }
            window.location.href = page.rtn;
        }, "json");
    }
};